package makabakaquestionnaire.zutsoftware.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import makabakaquestionnaire.zutsoftware.entity.struct.*;

@AllArgsConstructor
@Getter
public enum ProjectItemTypeEnum {
    NULL(0,"NULL",Object.class),
    INPUT(1, "单行文本", InputExpandStruct.class),
    COUNT(2, "计数器", TextareaExpandStruct.class),
    SELECT(3, "下拉框", SelectExpandStruct.class),
    NUMBER_INPUT(4, "数字输入", NumberExpandStruct.class),
    RADIO(5, "单选框", RadioExpandStruct.class),
    CHECKBOX(6, "多选框", CheckboxExpandStruct.class),
    SWITCH(7, "开关", SwitchExpandStruct.class),
    TIME(8, "时间选择", TimeExpandStruct.class),
    DATE(9, "日期选择", DateExpandStruct.class),
    RATE(10, "评分", RateExpandStruct.class),
    COLOR(11, "颜色", ColorExpandStruct.class),
    TIME_RANGE(12, "时间范围", TimeRangeExpandStruct.class),
    UPLOAD(17, "文件上传组件", UploadExpandStruct.class);

    private Integer value;

    private String desc;
    /**
     * 扩展属性类
     */
    private Class expandClass;

    /**
     * 枚举入参注解
     * @param value
     * @return
     */
   // @JsonCreator
//    public static ProjectItemTypeEnum getByValue(int value) {
//        for(ProjectItemTypeEnum typeEnum : values()) {
//            if(typeEnum.getValue() == value) {
//                return typeEnum;
//            }
//        }
//        return null;
//    }
    public static int getByValue(int value) {
        for(ProjectItemTypeEnum typeEnum : values()) {
            if(typeEnum.getValue() == value) {
                return typeEnum.value;
            }
        }
        return 0;
    }

}
